﻿#ifndef __mymain_H__
#define __mymain_H__
//#include "cocos2d.h"
#include "HitFx.h"
#include "TankScore.h"
#include "Control.h"
//using namespace cocos2d;
class MyMain : public CCLayer
{
    
public :
    
	CCRenderTexture*	m_target;
    CCRenderTexture*	m_target2;
    CCSpriteBatchNode *map;// :FlxGroupXY = new FlxGroupXY();
    CCSpriteBatchNode *bullet;// :FlxGroupXY = new FlxGroupXY();
    CCNode *bonus;// :FlxGroupXY = new FlxGroupXY();
    CCSpriteBatchNode *grass;// :FlxGroupXY = new FlxGroupXY();
	//CCNode *controls;
	// CCNode *drawl;
    
    //int timeAdd;// = 120;
    float timeTank;// = 1;
    
    //bool isBullet;// = true;
    //bool isbullet;// = true;
    //int timeBullet;// = 0;
    float timebullet;// = 0;
    
    int offerX;// = 0; // 36;//34
    int offerY;// = 0; // 17;
    
    int timeOver;// = 0;
	//  the:Main;
    
    static GameOver* mygameover;
	//  myobjs:Array;
	//  Num mytanklife;
    //Num *tankstage;
    TankScore* tankScore;
	
	// [Embed(source='../assets/bck1.png')]
	//  titlePagePNG:Class;
    
    //CCSprite* tankNum;
    CCNode *main;
    //Num *tankStage;
    //CCNode *start;// :FlxGroupXY;
    bool addtank;// :Boolean;
    
    bool tpressed_DOWN;
    bool tpressed_UP;
    bool tpressed_LEFT;
    bool tpressed_RIGHT;
    bool tpressed_SPACE;
	Control *control;
    
	// [Embed(source = '../assets/ice.png')]  starPNG:Class;
    static CCScene* scene() ;
    
    bool containp(CCRect r, CCPoint p) ;
    
    void directp(CCRect r, CCPoint p) ;
    
	
    virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
	virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
	virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);
	
    MyMain();
    bool init();
    CREATE_FUNC(MyMain);
    void testScore();
    
    void update(float dt);
    void replay() ;
    void addTanks(float dt) ;
    void gameOver();
    
    void nextLevel();
    
    void initMyTank();	//  static void setBoard()
	void destroyme();
    
    void initLevel(int level);
    //void clearTank() ;
    
   
    //void timeRun();
    
    void clearAll();
    void setBonus();
	void onMouseDown(int pid,CCPoint p);
	void onMouseMove(int pid,CCPoint p);
	void onMouseUp(int pid,CCPoint p);
    
    void map_drawMap(cocos2d::CCNode* mc, cocos2d::CCNode* grasss);
    void keyBackClicked();
    int did;
    int sid;
    CCLabelBMFont* _lbstage;
    CCLabelBMFont* _lbleave;
    void showChongtu(CCRect r,int r1,int r2,int c1,int c2,int i,int j);
   
    void drawCircle(CCRenderTexture* t,CCPoint p1,ccColor4F color);
    //CCRenderTexture*	m_target2;
    int debugct;
    CCRect lastchongtu;
    bool eqRect(CCRect r1,CCRect r2);
    bool eqFloat(float a,float b);
    bool eqPoint(CCPoint  a,CCPoint b);
    bool eqSize(CCSize  a,CCSize b);
	void showenemyNum();
	std::vector<int> homewalls;
	void repair();
	void walltogrid();
	bool alreadygrid;
	CCLabelBMFont* _lblife;
	void showLife();
};
#endif

